<html>
<head><meta charset="utf-8"><title>Why is rpath relative? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html">Why is rpath relative?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="158103543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158103543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158103543">(Feb 12 2019 at 09:21)</a>:</h4>
<p>In <a href="https://github.com/rust-lang/rust/issues/58343" target="_blank" title="https://github.com/rust-lang/rust/issues/58343">https://github.com/rust-lang/rust/issues/58343</a> I am describing some issue I am having with <code>-C rpath</code>. The biggest problem is that it is always relative, meaning that if the binary is moved, the rpath breaks. This is a problem because even <code>cargo build</code> will move the binary, meaning that rpath is basically useless when using cargo. (The absolute fallback path doesn't help at all, it points to a directory that does not even exist on my system.) Do you know why the rpath is relative?</p>



<a name="158103555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158103555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158103555">(Feb 12 2019 at 09:21)</a>:</h4>
<p>I guess an alternative would be to tweak <code>cargo build</code> and <code>cargo install</code> such that they always create the binary in the target directory instead of moving it after it got built.</p>



<a name="158118469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158118469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158118469">(Feb 12 2019 at 13:51)</a>:</h4>
<p>AIUI, rpath is intended to be relative <em>to the binary</em> so that you can ship around files like <code>mypackage/bin/program</code> and <code>mypackage/lib/mylib</code>and it will just find the right thing</p>



<a name="158118495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158118495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158118495">(Feb 12 2019 at 13:51)</a>:</h4>
<p><a href="https://stackoverflow.com/questions/40602708/linking-rust-application-with-a-dynamic-library-not-in-the-runtime-linker-search" target="_blank" title="https://stackoverflow.com/questions/40602708/linking-rust-application-with-a-dynamic-library-not-in-the-runtime-linker-search">https://stackoverflow.com/questions/40602708/linking-rust-application-with-a-dynamic-library-not-in-the-runtime-linker-search</a></p>



<a name="158118547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158118547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158118547">(Feb 12 2019 at 13:52)</a>:</h4>
<p>e.g. <code>cargo rustc -- -C link-args='-Wl,-rpath,$ORIGIN/../../../library/'</code></p>



<a name="158118615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158118615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158118615">(Feb 12 2019 at 13:53)</a>:</h4>
<p>ah, <code>-C link-args</code> sounds great</p>



<a name="158118618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Why%20is%20rpath%20relative%3F/near/158118618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Why.20is.20rpath.20relative.3F.html#158118618">(Feb 12 2019 at 13:53)</a>:</h4>
<p>I can just add my absolute path there...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>